import com.alibaba.fastjson2.JSON;
import com.emmmya.harinCheck.engine.impl.DefaultHarinCheckEngine;
import com.emmmya.harinCheck.engine.utils.DefaultCheckUtils;
import com.emmmya.harinCheck.pojo.Status;
import com.emmmya.harinCheck.pojo.TestEntity;
import com.emmmya.harinCheck.pojo.entity.GoogleUploadEntity;
import com.emmmya.harinCheck.result.CheckResult;
import com.emmmya.harinCheck.utils.EnumGetValueUtils;
import com.emmmya.harinCheck.utils.RegexUtils;

import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Date;
import java.util.Map;

/**
 * @author laijieguan@sunwodao.com
 * @version 1.0
 * @date 2022-06-28 15:46:43
 */
public class testMain {


    public static void main(String[] args) {

        try {
            String jsonPath = "D:\\Users\\2003030042\\Desktop\\13G_1685059078000_2023052607575813G8230036901AA35K01715.json";
            File file = new File(jsonPath);

            BufferedReader br = new BufferedReader(new FileReader(file));
            StringBuffer sb = new StringBuffer();
            String line;
            while((line = br.readLine()) != null){
                sb.append(line);
            }
            GoogleUploadEntity googleUploadEntity = JSON.parseObject(sb.toString(), GoogleUploadEntity.class);
            CheckResult check = DefaultCheckUtils.check(DefaultHarinCheckEngine.class, googleUploadEntity,true);
            System.out.println(check);
            System.out.println(googleUploadEntity.getMetadata().getDeviceId());
        } catch (Exception e) {
            e.printStackTrace();
        }


//        boolean aaa = RegexUtils.findAny("^[a-zA-Z-z0-9]+$", "1163985018000AS58s44209");
//        System.out.println(aaa);
        /*TestEntity testEntity = new TestEntity();
        try {
            //System.out.println(staus.success);
            testEntity.setUsername("laijieguan");
            testEntity.setPassword("Jieguan1994.");
            testEntity.setSex(99);
            testEntity.setA(13);
            testEntity.setB(14);
            testEntity.setBirthday(new Date(759399230));
            testEntity.setNow(new Date());
            testEntity.setStatus(200);
            //CheckResult check = DefaultCheckUtils.check(DefaultHarinCheckEngine.class,testEntity);
            //System.out.println(check);
            Object enumValue = EnumGetValueUtils.getEnumValue(Status.class, 200);
            System.out.println(enumValue);
            //getEnumMap(staus.class);




        } catch (Exception e) {
            e.printStackTrace();
        }*/

    }



    /**
     * 根据类名获取枚举的键值集合
     * @param enumClass
     * @return
     * @throws NoSuchMethodException
     */
    private static Map<Object, Object> getEnumMap(Class<?> enumClass){
        try {
            Method getDataMapMethod = enumClass.getDeclaredMethod("getDataMap");
            Map<Object,Object> invoke = (Map<Object,Object>)getDataMapMethod.invoke(null, null);
            return invoke;
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }
}
